<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Group extends CI_Controller {

	public function index()
	{
            $page = array();
            $this->load->helper('html');
            $this->load->model('Objects_model');
            //print_r($this->CAgent_model->aList());
            
            $page['content'] = $this->load->view('Objects/ObjectsList', array( 'wh_list' => $this->Objects_model->GetObjects(NULL, FALSE)), TRUE);
            $this->parser->parse('MasterPage', $page);
        
	}
        /**
         * Добавление контрагента
         */
        public function add()
        {
            
            $this->load->library('form_validation');
            
            $this->form_validation->set_rules('groupName', 'Группа', 'trim|required|max_lenght[50]');

            
            
            if ($this->form_validation->run() == FALSE)
            {
                $page['content'] = $this->load->view('Group/GroupAdd', array(), TRUE);
            }
            else
            {
                $this->load->model('Group_model');
                $this->Group_model->SaveGroup(
                        $this->input->post('groupName')
                );
                redirect('objects');
            }        
            //$page['content'] = 'Comming soon';
            $this->load->view('MasterPage', $page);
        }
}

